<?
include ('../common/autoload.php');
include_once ('/var/www/html/new/com.inc.php');
$ac=$GLOBALS['_ac'];
$pw=$GLOBALS['_pw'];
$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));


$sale = new \pft\Prod\Sale($GLOBALS['le'], $_SESSION['sid']);
// 二手销售数据
//$sql_get = 
//"SELECT e.fid,e.pid
//FROM pft_p_apply_evolute e left join uu_products p ON p.id=e.pid
//WHERE fid={$_SESSION['sid']}";
//$edatas = $epid_arr = $sid_pid = array();
//$GLOBALS['le']->query($sql_get);
//$pid_arr = array();
//while($r=$GLOBALS['le']->fetch_assoc()) {
  // $pid_arr[]=$r['pid'];
   // $edatas[] = $r;
    //$epid_arr[] = $r['pid'];
    //$sid_arr[]  = $r['sid'];
//}
//print_r($pid_arr);
// 一手直接供应可购买的产品 pid
$pid_arr_2 = $sale->GetProdsid();
//print_r($pid_arr_2);
//$harray=array_merge($pid_arr,$pid_arr_2);
$r=array_unique($pid_arr_2);
$pid_str=implode(',',$r);
echo $pid_str;
$ustr="select p.contact_id from uu_products p where p.id in($pid_str)";
$GLOBALS['le']->query($ustr);
while($rl=$GLOBALS['le']->fetch_assoc())
{     $r2[]=$rl['contact_id'];   
     //$rd[]=$rl['lid'];
}
$r2=array_unique($r2);
$cid_str=implode(',',$r2);
//echo $cid_str;
$lstr="select id,title from uu_land where id in($cid_str)";
  $GLOBALS['le']->query($lstr);
  while($ur=$GLOBALS['le']->fetch_assoc())
  { $ultitle[]=$ur['title'];   }
  //print_r($ultitle);
  //print_r ($r);
 //$r=implode(',',$r);
 //$r=explode(',',$r);
 //$r=array_unique($r);
 //$r=array_merge($rd,$rt);







// 没有一手的并且二手以上的有
//if(!count($pid_arr) && count($epid_arr)>0) {
  //  $pid_arr = $epid_arr;
//}
// 一手供应的产品信息
//$pids = implode(',',$pid_arr);
//$pids = str_replace(',,',',',$pids);//某些错误的记录里会导致两个逗号中间是空的 
//$sql_apply_did = "SELECT id,apply_did FROM uu_products WHERE id IN($pids) AND apply_limit=1 AND p_status IN(0,2,3,4,5)";
//$GLOBALS['le']->query($sql_apply_did);
//while($list = $GLOBALS['le']->fetch_assoc()){
   // $prod_init_prod[] = array(
        //'fid'=>$_SESSION['sid'],
        //'pid'=>$list['id'],
   // }

// 合并一手供应及多级供应的产品 PID
//$pid_str = implode(',',$pid_arr);
//$pid_arr = array_merge($epid_arr, explode(',', $pid_str));
//$uniq_pid = $pid_arr = array_unique($pid_arr);

// 获取唯一的景区门票信息
//$pid_str = implode(',', $uniq_pid);
//$pid_str = str_replace(',,',',',$pid_str);
//$sql = "SELECT t.id as ticket_id, t.landid, l.title as ltitle,t.title as ttitle,t.pid, t.pay FROM uu_jq_ticket t LEFT JOIN uu_land l ON l.id=t.landid WHERE t.pid IN($pid_str)";
//echo $sql;
//$GLOBALS['le']->query($sql);
//$data = array();
//while($l = $GLOBALS['le']->fetch_assoc()) {
    //$data[$l['pid']] = $l;
	//}
	//print_r($l);
//include("/var/www/html/new/class/Member.php");
//$land = array();
//$m = new Member($s,$memberID);
//$sale = $m->salePros();
//foreach($sale as $v){
 //   $strid.=$v['lid'].",";
//}

//print_r($v['lid']);
//$strid=substr($strid,0,-1);
//$arrayids=explode(',',$strid);
//$arrayids=array_unique($arrayids);
//print_r(array_unique($arrayids));
//echo $strid;

//include_once '/var/www/html/new/com.inc.php';
//$ac=$GLOBALS['_ac'];
//$pw=$GLOBALS['_pw'];
//$s = new SoapClient(null,array("location" => "http://localhost/open/openService/pft_insideMX.php","uri" => "www.16u.com?ac_16u=$ac|pw_16u=$pw|auth_16u=true"));
//$aid=$_SESSION['sid'];
//$btime=date('Y-m-d',strtotime("-30days"));
//$etime=date('Y-m-d');
//$bt= $btime .' 00:00:00';
//$et = $etime .' 23:59:59'; 

//$x = simplexml_load_string($s -> Order_Globle_Search( 
    // "","$aid", "", "", "", "", "", "", "", "",
     //"$bt", "$et", "", "", "", "1", "", "", "1", "1",
     //"0", "1000", "0", "0","","0","0", "0","","",
      //"", "", "", "", ""));
	
	
 //$sel_lid = "select id,title from uu_land where apply_did={$_SESSION['sid']}";
 //$le->query($sel_lid);
 //$le->fetch_assoc();
 //while($row=$GLOBALS['le']->fetch_assoc()){
 //$r[] = $row;
 //}
//$weekSales= $weekSales;
//print_r($weekSales);
?>
<link rel="stylesheet" type="text/css" href="http://www.12301.cc/css/select2.css">
	<style type="text/css">
		#saleReprotMod{ width:600px;}
		#ctrlContainer{ margin-bottom:5px;}
		#ctrlContainer label{ position:relative; top:1px; font-size:12px; cursor:pointer}
		#ctrlContainer input.dateTrigger{ position:relative; top:3px; cursor:pointer; margin-right:1px; margin-left:15px;}
		#echartContainer{ height:400px; border:1px solid #e1e1e1; border-radius:3px; padding:8px; background:rgb(247,247,247)}
		#echartContainerCon{ height:100%; width:100%;}
		#s2id_jqSelect{ width:359px;}
		/*.select2-container{ display:block; margin-bottom:10px;}*/
		.select2-container .select2-choice{ broder-radius:2px; border-color:#e1e1e1}
		#startTimeInp{ width:217px; height:32px; padding:0 5px; padding-left:8px; margin-bottom:5px; border:1px solid #e1e1e1; border-radius:2px; background:url(http://www.12301.cc/images/dateIcon.png) no-repeat 99%}
		.select2-container .select2-choice{ height:32px; line-height:32px;}
		.select2-container .select2-choice .select2-arrow{ width:30px;}
		#saleReprotMod .btnW{ margin-top:10px; text-align:right}
		#saleReprotMod .tp{ margin-top:10px; padding-bottom:8px; margin-bottom:6px; border-bottom:1px solid #E1E1E1}
		#saleReprotMod .tp .txt{ height:16px; line-height:16px; padding:0; margin:0; padding-left:3px; border-left:3px solid #3E3E3E; font-size:14px; color:#3E3E3E; font-weight:bold}
		#saleReprotMod .tp .icon{ display:inline-block; width:10px; height:10px; margin-right:3px; background:#008EC1;}
		/* 日历插件样式 */
		#calendarPanel{ width:231px; height:208px; padding:5px 0px; background:url(http://www.12301.cc/images/calendarPannelWrap.gif) no-repeat 0 0}
		#calendarPanel .calTopW{ width:100%; position:relative; height:28px;}
		#calendarPanel .selectW{ overflow:hidden; margin:0 30px; text-align:center;}
		#calendarPanel .calTopW input{ position:absolute; top:3px; display:block; width:22px; height:19px; cursor:pointer; font-size:0; border:0 none; background:none;}
		#calendarPanel #prevMonth{ left:10px;}
		#calendarPanel #nextMonth{ right:9px;}
		#calendarPanel .selectW select{ height:24px; line-height:24px; width:77px;}
		#calendarYear{ margin-right:5px;}
		#calendarTable thead{ height:28px;}
		#calendarTable thead th{ text-align:center; font-weight:bold;}
		#calendarTable tbody{ }
		#calendarTable tbody td{ height:23px; border-right:1px solid #ececec;border-bottom:1px solid #ececec}
		#saleReprotMod .endTimetip{ display:none; font-size:12px; color:#9c9c9c}
		#saleReprotMod .echartBtn{ display:inline-block; height:32px; line-height:32px; padding:0 30px; font-size:12px; color:#fff; border-radius:3px; cursor:pointer; broder:1px solid #fff; margin-right:10px;}
		#saleReprotMod .echartBtn.query{ margin-left:20px; background:#d87329; border-color:#a95416}
		#saleReprotMod .echartBtn.query:hover{ background:#eb7d2c;}
		#saleReprotMod .echartBtn.refresh{ background:#50b350; border-color:#2d852d}
		#saleReprotMod .echartBtn.refresh:hover{ background:#60c760; border-color:#4cae4c}
	    .btnW{display:none;}
	</style>
    <div id="saleReprotMod" class="saleReprotMod">
	    <div class="tp"><p class="txt">销量统计报表</p></div>
	    <div id="ctrlContainer" class="ctrlContainer">
		    <!--<input type="text" name="btime3" id="startTimeInp" class="startTimeInp" onmouseup="SelectDate(this,'yyyy-MM-dd',0,0)" value="2015-03-03">-->
           <select name="lid" id="jqSelect" tabindex="-1" title="">
               <?
               if($ultitle){
			    foreach($ultitle as $lid=>$v){ 
                ?>
	           <option value="<?=$lid?>"><?=$v?></option>
	           <?}}else{?>
	           <option value="">请选择景区</option>
	           <?}?>
            </select>
		    <input id="threeDayTrigger" checked="checked" class="dateTrigger threeDayTrigger" type="radio" name="dateTrigger" value="<?=date('Y-m-d',strtotime('-3days'))?>"/><label for="threeDayTrigger">3天内</label>
		    <input id="weekTrigger" class="dateTrigger weekTrigger" type="radio" name="dateTrigger" value="<?=date('Y-m-d',strtotime('-7days'))?>"/><label for="weekTrigger">1周内</label>
		    <input id="monthTrigger" class="dateTrigger monthTrigger" type="radio" name="dateTrigger" value="<?=date('Y-m-d',strtotime('-30days'))?>"/><label for="monthTrigger">1个月内</label>
			<!--<span class="endTimetip">结束时间默认至今天</span>-->
	    </div>
	    <div id="echartContainer" class="echartContainer"><div id="echartContainerCon" class="echartContainerCon"></div></div>
	    <div class="btnW">
		    <span id="queryChartBtn" class="echartBtn query">查询</span>
		    <span style="margin-right:0" id="refreshChartBtn" class="echartBtn refresh">刷新</span>
	    </div>
    </div>
	<script type="text/javascript" src="http://www.12301.cc/js/echarts-2.2.0/build/dist/echarts-all.js"></script>
	<script type="text/javascript" src="http://www.12301.cc/js/global/www.12301.cc.global.js"></script>
    <script type="text/javascript" src="http://www.12301.cc/js/zy_Calendar.js"></script>
    <script type="text/javascript" src="http://www.12301.cc/js/select2.js"></script>
	<script type="text/javascript" src="http://www.12301.cc/js/z_sale_reportz2.js"></script>